package org.springblade.modules.rotation;

import org.springframework.stereotype.Service;

@Service
public class TaskService {

    private final DynamicScheduler dynamicScheduler;

    public TaskService(DynamicScheduler dynamicScheduler) {
        this.dynamicScheduler = dynamicScheduler;
    }

    public void createDynamicTask(String taskId, String cronExpression) {
        dynamicScheduler.addOrUpdateTask(taskId, cronExpression, () -> {
            // 这里写你的任务逻辑
            System.out.println("执行动态任务: " + taskId + ", 时间: " + System.currentTimeMillis());

            // 可以在这里添加业务逻辑
            // yourBusinessService.doSomething();
        });
    }
}
